<template>
  <section class="oa-form__table">
    <h5>{{approve.name}}</h5>
    <table cellpadding="0" cellspacing="0">
      <tr v-if="$route.query.from != 'new'">
        <td>事务编号</td>
        <td>
          {{ approve.name }}
          <span v-if="approve && approve.code">{{ approve.code }}</span>
        </td>
      </tr>
      <tr>
        <td>流程名称</td>
        <td>
          <span v-if="$route.query.from == 'new'">
            新建{{approve.name}}
          </span>
          <span v-else>
            {{approve.approve_name}}
          </span>
        </td>
      </tr>
      <tr>
        <td>申请事由</td>
        <td :title="reason"><el-input placeholder="申请事由" type="textarea" v-model="reason" :disabled="$route.query.from != 'new'"/></td>
      </tr>
    </table>
    <h3 class="oa-form__table-title">
      <span v-if="$route.query.from === 'new'">{{ approve.name }}</span>
      <span v-else>
        {{ approve.approve_name }}
      </span>
    </h3>
    <table  class="achievement__tab">
      <tr class="border_0">
        <td>考核周期:</td>
        <td>
          <el-date-picker
            value-format="yyyy-MM-dd"
            type="date"
            v-model="applyTime"
            :disabled="$route.query.from !== 'new'"
            placeholder="考核周期">
          </el-date-picker>
        </td>
        <td>部门:</td>
        <td>
          <el-select v-model="department" :disabled="$route.query.from != 'new'" placeholder="请选择">
            <el-option
              v-for="item in departments"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </td>
        <td>姓名:</td>
        <td>
          <el-select v-model="value" style="width:60%" :disabled="$route.query.from != 'new'" placeholder="请选择"  @change="selectStaff($event)">
            <el-option
              v-for="item in staff"
              :key="item.value"
              :label="item.label"
              :value="item">
            </el-option>
          </el-select>
        </td>
        <!-- <td>岗位:</td> -->
        <td>岗位:<span style="display:inline-block;width:100px;padding-left:10px;"><el-input v-model="gangwei" :disabled="$route.query.from !== 'new'" placeholder="岗位"/></span></td>
      </tr>
      <tr>
        <td class="_name">考核指标</td>
        <td class="_name">指标定义</td>
        <td class="_name">权重</td>
        <td class="_name" width="300">评分说明</td>
        <td class="_name">评定人</td>
        <td class="_name">自评</td>
        <td class="_name">评估</td>
        <!-- <td class="_name">事项说明</td> -->
      </tr>
      <tr>
        <td rowspan="4">HR</td>
        <td>招聘</td>
        <td>30%</td>
        <td>
          根据公司经营需求，每月刷选简历150份，部门邀约到面人数10人,定期提供招聘相关报表:累
          计年度员工流失率（<span class="c_red">不含试用期离职</span>)不超过15%;确定需求岗位人员在一个月内完成招聘:每
          月提出招聘合理化建议（<span class="c_red">-周内完成+4分，二周内完成+2分，超时--次扣2分:员工流失率15%
          &lt;R&lt;20%扣2分，R&gt;20%扣4分</span>)
        </td>
        <td>直属上级</td>
        <td><el-input v-model="obj.a634" :disabled="$route.query.from !== 'new'" /></td>
        <td><el-input v-model="obj.a641" :disabled="obj.a641Flag" /></td>
      </tr>
      <tr>
        <td>薪酬/绩效</td>
        <td>20%</td>
        <td>每月9日前完成绩效考核统计.薪资核算.在-天内反馈员工申诉事宜（<span class="c_red">超时-天扣3分</span>)</td>
        <td>直属上级</td>
        <td><el-input v-model="obj.a635" :disabled="obj.a635Flag" /></td>
        <td><el-input v-model="obj.a642" :disabled="obj.a642Flag" /></td>
        <!-- <td>&nbsp;</td> -->
      </tr>
      <tr>
        <td>培训</td>
        <td>10%</td>
        <td>每月10日前做好新进员工入职培训:根据培训计划实施培训工作（<span class="c_red">超时-次扣2分</span>)</td>
        <td>直属上级</td>
        <td><el-input v-model="obj.a636" :disabled="obj.a636Flag" /></td>
        <td><el-input v-model="obj.a643" :disabled="obj.a643Flag" /></td>
        <!-- <td>&nbsp;</td> -->
      </tr>
      <tr>
        <td>员工关系</td>
        <td>10%</td>
        <td>
          在员工入（<span class="c_red">离</span>)职-个月内办理入（<span class="c_red">离</span>)职手续、劳动合同、社保、置升.转岗、员工档案等用
          工事项（<span class="c_red">超时--次扣3分</span>)
        </td>
        <td>直属上级</td>
        <td><el-input v-model="obj.a637" :disabled="obj.a637Flag" /></td>
        <td><el-input v-model="obj.a644" :disabled="obj.a644Flag" /></td>
        <!-- <td>&nbsp;</td> -->
      </tr>
      <tr>
        <td rowspan="2">行政事务</td>
        <td>重大活动组织执行</td>
        <td>10%</td>
        <td>
          限据公司大事记筹备执行包括但不限于中秋、尾牙、年中、年终总结等活动（<span class="c_red">根据员工满意度/
          高效完成度来评分</span>)
        </td>
        <td>直属上级</td>
        <td><el-input v-model="obj.a638" :disabled="obj.a638Flag" /></td>
        <td><el-input v-model="obj.a645" :disabled="obj.a645Flag" /></td>
        <!-- <td>&nbsp;</td> -->
      </tr>
      <tr>
        <td>OA系统</td>
        <td>10%</td>
        <td>每月10日前将上月HR部门文件，上月的公司各项标准文件上传存档（<span class="c_red">超时--次扣3分</span>)</td>
        <td>直属上级</td>
        <td><el-input v-model="obj.a639" :disabled="obj.a639Flag" /></td>
        <td><el-input v-model="obj.a646" :disabled="obj.a646Flag" /></td>
        <!-- <td>&nbsp;</td> -->
      </tr>
      <tr>
        <td>公司制度执行</td>
        <td>遵守公司规章制度</td>
        <td>10%</td>
        <td>对公司制度及公司文化的理解和执行。目标与时间管理.事必有复复必有时。</td>
        <td>管导</td>
        <td><el-input v-model="obj.a640" :disabled="obj.a640Flag" /></td>
        <td><el-input v-model="obj.a647" :disabled="obj.a647Flag" /></td>
        <!-- <td>&nbsp;</td> -->
      </tr>
      <tr>
        <td rowspan="2">加分项</td>
        <td>增量工作内容</td>
        <td>&nbsp;</td>
        <td>超出岗位职责范围、领导交办较为繁杂的事务、工作表现卓越等</td>
        <td>总经理</td>
        <td><el-input v-model="obj.a648" :disabled="obj.a648Flag" /></td>
        <td><el-input v-model="obj.a650" :disabled="obj.a650Flag" /></td>
        <!-- <td rowspan="2">
          经主管评估提报
          始总经理评分
        </td> -->
      </tr>
      <tr>
        <!-- <td>&nbsp;</td> -->
        <td>对公司的建议</td>
        <td>&nbsp;</td>
        <td>对市场拓展、业务销售、内部管理等建设性意见</td>
        <td>总经理</td>
        <td><el-input v-model="obj.a649" :disabled="obj.a649Flag" /></td>
        <td><el-input v-model="obj.a651" :disabled="obj.a651Flag" /></td>
      </tr>
      <tr>
        <td colspan="3">自评:{{myScore}}</td>
        <td colspan="5">综合考核率:{{otherScore}}</td>
      </tr>
      <tr>
        <td colspan="8">员工流失率=员工流失人数+（<span class="c_red">期初员工人数+期末员工人数</span>)/2x100%</td>
      </tr>
    </table>
    <history :process="process"></history>
    <files></files>
  </section>
</template>
<script>
import mixin from '@/mixins/index.js'
import history from '../service/components/process'
import files from '../service/components/files'
import { sum } from '@/utils/domUtils.js'
const obj = {}
for (let i = 634; i <= 651; i++) {
  obj[`a${i}`] = ''
  obj[`a${i}Flag`] = true
}
// for (let i = 678; i <= 679; i++) {
//   obj[`a${i}`] = ''
//   obj[`a${i}Flag`] = true
// }
export default {
  mixins: [mixin],
  data () {
    return {
      reason: '',
      truename: '',
      department: '',
      flag: false,
      value: '',
      obj: JSON.parse(JSON.stringify(obj)),
      applyTime: '',
      gangwei: '',
      file_paths: [],
      file_names: [],
      field_ids: [],
      field_vals: [],
      autoField: []
    }
  },
  components: { history, files },
  props: ['curDepartment', 'userInfo', 'approve', 'staff', 'addDofield', 'departments', 'process'],
  computed: {
    uploadArr () {
      return this.$store.state.uploadArr
    },
    myScore () {
      const result = []
      for (let i = 634; i <= 640; i++) {
        if (this.obj[`a${i}`]) {
          result.push(this.obj[`a${i}`])
        }
      }
      for (let i = 648; i <= 649; i++) {
        if (this.obj[`a${i}`]) {
          result.push(this.obj[`a${i}`])
        }
      }
      return sum(result)
    },
    otherScore () {
      const result = []
      for (let i = 641; i <= 647; i++) {
        if (this.obj[`a${i}`]) {
          result.push(this.obj[`a${i}`])
        }
      }
      result.push(this.obj.a651)
      result.push(this.obj.a650)
      return sum(result)
    }
  },
  watch: {
    addDofield () {
      this.addDofieldRender()
    }
  },
  mounted () {
    this.$nextTick(() => {
      this.obj = JSON.parse(JSON.stringify(obj))
      if (this.$route.query.from === 'new') {
        this.disabled = true
      } else {
        this.infoFunc()
      }
      this.addDofieldRender()
    })
  },
  methods: {}
}
</script>
